/// 上传规则枚举
enum UploadRule {
  /// 全部上传
  all,

  /// AI筛选后上传
  aiFiltered,

  /// 手动选择上传
  manualSelection,
}

/// 上传规则扩展方法
extension UploadRuleExtension on UploadRule {
  /// 获取显示名称
  String get displayName {
    switch (this) {
      case UploadRule.all:
        return '全部上传';
      case UploadRule.aiFiltered:
        return 'AI筛选后上传';
      case UploadRule.manualSelection:
        return '手动选择上传';
    }
  }

  /// 获取描述
  String get description {
    switch (this) {
      case UploadRule.all:
        return '上传所有拍摄的照片';
      case UploadRule.aiFiltered:
        return '仅上传通过AI筛选的优质照片';
      case UploadRule.manualSelection:
        return '由用户手动选择要上传的照片';
    }
  }
}

/// AI挑图设置模型
///
/// 表示AI挑图的各项检测功能配置
class AIPickSettings {
  /// 上传规则
  final UploadRule uploadRule;

  /// 重复图片检测是否开启
  final bool duplicateDetectionEnabled;

  /// 闭眼图片检测是否开启
  final bool eyesClosedDetectionEnabled;

  /// 过曝图片检测是否开启
  final bool overexposureDetectionEnabled;

  /// 欠曝图片检测是否开启
  final bool underexposureDetectionEnabled;

  /// 图片清晰度检测是否开启
  final bool clarityDetectionEnabled;

  const AIPickSettings({
    required this.uploadRule,
    required this.duplicateDetectionEnabled,
    required this.eyesClosedDetectionEnabled,
    required this.overexposureDetectionEnabled,
    required this.underexposureDetectionEnabled,
    required this.clarityDetectionEnabled,
  });

  /// 创建副本
  AIPickSettings copyWith({
    UploadRule? uploadRule,
    bool? duplicateDetectionEnabled,
    bool? eyesClosedDetectionEnabled,
    bool? overexposureDetectionEnabled,
    bool? underexposureDetectionEnabled,
    bool? clarityDetectionEnabled,
  }) {
    return AIPickSettings(
      uploadRule: uploadRule ?? this.uploadRule,
      duplicateDetectionEnabled:
          duplicateDetectionEnabled ?? this.duplicateDetectionEnabled,
      eyesClosedDetectionEnabled:
          eyesClosedDetectionEnabled ?? this.eyesClosedDetectionEnabled,
      overexposureDetectionEnabled:
          overexposureDetectionEnabled ?? this.overexposureDetectionEnabled,
      underexposureDetectionEnabled:
          underexposureDetectionEnabled ?? this.underexposureDetectionEnabled,
      clarityDetectionEnabled:
          clarityDetectionEnabled ?? this.clarityDetectionEnabled,
    );
  }

  @override
  String toString() {
    return 'AIPickSettings(uploadRule: ${uploadRule.displayName}, '
        'duplicate: $duplicateDetectionEnabled, eyesClosed: $eyesClosedDetectionEnabled, '
        'overexposure: $overexposureDetectionEnabled, underexposure: $underexposureDetectionEnabled, '
        'clarity: $clarityDetectionEnabled)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is AIPickSettings &&
        other.uploadRule == uploadRule &&
        other.duplicateDetectionEnabled == duplicateDetectionEnabled &&
        other.eyesClosedDetectionEnabled == eyesClosedDetectionEnabled &&
        other.overexposureDetectionEnabled == overexposureDetectionEnabled &&
        other.underexposureDetectionEnabled == underexposureDetectionEnabled &&
        other.clarityDetectionEnabled == clarityDetectionEnabled;
  }

  @override
  int get hashCode {
    return Object.hash(
      uploadRule,
      duplicateDetectionEnabled,
      eyesClosedDetectionEnabled,
      overexposureDetectionEnabled,
      underexposureDetectionEnabled,
      clarityDetectionEnabled,
    );
  }
}
